<?php 
$itemsPerPage = 10;
$pageParameter = "articlesPage";

$i = 0;
$page = 1;
if(pc_variable($pageParameter) !== null) {
    $page = pc_variable($pageParameter);
}
$articles = pc_variable("commerce.articles");
$count = $articles->size();
if($count == 0) { ?>
	<p><?php pc_echo(pc_message("articles.noneFound")); ?></p>
<?php }
if($count > $itemsPerPage) { 
    pc_pagelet("common/paging",
        array(
            "pageParameter" => $pageParameter,
            "pages" => ceil($count / $itemsPerPage),
            "currentPage" => $page
        )); 
}
foreach($articles as $article) {
    if($i >= ($page - 1) * $itemsPerPage && $i < $page * $itemsPerPage) {
        pc_pagelet("articles/list-item",
            array("commerce.article" => $article));
    }
    $i++;
} 
if($count > $itemsPerPage) { 
    pc_pagelet("common/paging",
        array(
            "pageParameter" => $pageParameter,
            "pages" => ceil($count / $itemsPerPage),
            "currentPage" => $page
        )); 
} ?>